package com.dm.cloud.core.config.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateCustomizer;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * @Author sg
 * @ClassName CustomRestTemplateCustomizer.java
 * @Description 添加自定义拦截器到restTemplate
 * @Date 2021/08/18 14:08
 */
@Component
public class CustomRestTemplateCustomizer implements RestTemplateCustomizer {

    @Autowired
    CustomClientHttpRequestInterceptor customClientHttpRequestInterceptor;

    @Override
    public void customize(RestTemplate restTemplate) {
        restTemplate.getInterceptors().add(customClientHttpRequestInterceptor);
    }
}